package com.example.lenovo.test01.listview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.TextView;

import com.example.lenovo.test01.R;
public class MyListAdapter extends BaseAdapter {

    private Context mcontext;
    private LayoutInflater mLayoutInflater;

    MyListAdapter(Context context){
        this.mcontext = context;
        mLayoutInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return 8;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    static class ViewHolder{
        public TextView textView;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView==null){
            convertView = mLayoutInflater.inflate(R.layout.activity_list,null);
            holder = new ViewHolder();
            holder.textView = convertView.findViewById(R.id.tv1);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        //给控件赋值
        holder.textView.setText("Android大作业");
        return convertView;
    }
}
